#include <stdlib.h>
#include <stdio.h>

#include "preforkserver.h"

const int SHMKEY = 1234555;
const int SUBPROCNUMB = 20;

class PreForkServerImpl : public PreForkServer
{
public:
	PreForkServerImpl(int key, unsigned int aiSubprocnum):PreForkServer(key,aiSubprocnum){};
protected:
	virtual void ChildRun();
	virtual void BeforeChildRun();
};

void PreForkServerImpl :: ChildRun()
{
	while (true)
	{
		sleep(1);
		printf("child[%d] is running\n",getpid());
	}
}

void PreForkServerImpl :: BeforeChildRun()
{
}

int main(int argc, char* argv[])
{ 
	int ret = -1;
	PreForkServerImpl server(SHMKEY, SUBPROCNUMB);
	ret = server.Init();

	if (ret == 0)
	{
		server.Run();
	}
	else
	{
		printf("Server Init fail, ret %d\n",ret);
	}

	return 0;
}
